package com.mx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mx.mapper.UserMapper;
import com.mx.pojo.User;
import com.mx.pojo.vo.UserVO;
import com.mx.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author MinXu
 * @since 2021-07-28
 * QQ   754647431
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
    @Autowired
    UserMapper userMapper;

    public UserVO findUserById(Integer id) {
        return new UserVO(userMapper.selectById(id));
    }

    public UserVO verifyUser(String username, String password) {
        User user = userMapper.selectOne(new QueryWrapper<User>().eq("username", username).eq("password", "password"));
        if (user == null) {
            return null;
        }
        return new UserVO(user);
    }
}
